<script lang="ts" setup>
import "@/utils/rem"
import { ref } from "vue"
import { getComboDetail } from "@/api/hr"
import { useRouter } from "vue-router"

// import { formatDateTime } from "@/utils"
// import { showToast } from "vant"
const router = useRouter()
const counts = ref<any>(0)
const list = ref<any>([])
const loading = ref(false)
const finished = ref(false)
const BASEURL = `${import.meta.env.VITE_BASE_API}/image/`
const refreshing = ref(false)
const name = ref<any>(router.currentRoute.value.query.n) //名字
const phone = ref<any>(router.currentRoute.value.query.p) //手机号

const onLoad = () => {
  getComboDetail({
    name: name.value,
    phone: phone.value
  })
    .then((res: any) => {
      if (res.code == 200) {
        if (refreshing.value) {
          list.value = []
          refreshing.value = false
        }
        list.value.push(...res.data)
        counts.value = res.data.total
        document.title = "我投递的简历"
      }
    })
    .catch(() => {
      list.value = []
    })
  loading.value = false

  if (list.value.length >= counts.value) {
    finished.value = true
    console.log(counts.value, list.value.length)
  }
}

const goCreateOrder = (item: any) => {
  router.push(`/hr/details?uid=${item.id}`)
}
/**END */
defineOptions({
  name: "OrderSearch"
})
</script>
<template>
  <div style="background-color: #f9faff; width: 7.5rem; margin: 0 auto" ref="root">
    <div class="tabs-box">
      <div class="list">
        <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad">
          <van-cell v-for="item in list" :key="item.id" style="margin-bottom: 0.2rem">
            <van-card :title="`${item.name}`" :centered="false" @click="goCreateOrder(item)">
              <template #desc>
                <div class="van-ellipsis" style="font-size: 14px">
                  {{ item.age }}
                  {{ item.education || "" }}
                  {{ item.hopeSalary || "" }}
                  {{ item.phone }}
                </div>
                <div class="van-ellipsis" style="padding: 0.2rem 0; font-size: 14px">面试岗位：{{ item.works }}</div>
                <div class="van-ellipsis" style="font-size: 14px">
                  毕业学校：{{ item.schoolName }} {{ item.specialty }}
                </div>
              </template>
              <template #thumb>
                <el-image
                  class="box-img"
                  fit="cover"
                  v-if="!item.img && item.sex === '女'"
                  src="http://fansitexitong.cn/images/gril.png"
                  alt=""
                />
                <el-image
                  class="box-img"
                  fit="cover"
                  v-else-if="!item.img && item.sex === '男'"
                  src="http://fansitexitong.cn/images/boy.png"
                  alt=""
                />
                <el-image
                  class="box-img"
                  fit="cover"
                  v-else
                  style="width: 2.2rem; height: 2.4rem"
                  :src="`${BASEURL}${item.img}`"
                  alt=""
                />
              </template>
            </van-card>
          </van-cell>
        </van-list>
      </div>
    </div>
  </div>
</template>
<style lang="scss" scoped>
.title {
  background-color: #fff;
  // text-align: right;
  // padding: 0.1rem 0.2rem;
  box-sizing: border-box;
}
.list {
  padding: 0.2rem;
  // margin: 0.2rem 0;
}
.notice-swipe {
  width: 1.4rem;
  height: 0.4rem;
  line-height: 0.4rem;
}
:deep(.van-card__content) {
  text-align: left !important;
}
:deep(.van-card) {
  background-color: #fff !important;
}
:deep(.van-cell) {
  border-radius: 0.2rem;
}
.tagY {
  background: linear-gradient(137deg, #fa9d5d, #ff3162);
  border-radius: 2px;
  color: #fff;
  font-size: 10px;
  height: 18px;
  line-height: 18px;
  margin-right: 10px;
  padding: 3px 7px;
  z-index: 9;
}
:deep(.van-card__thumb) {
  width: 2.2rem !important;
  height: 2.4rem !important;
}
:deep(.van-card__bottom) {
  text-align: right;
}

:deep(.van-card__desc) {
  color: #000;
  vertical-align: middle;
  font-size: 14px;
}
:deep(.van-card__title) {
  color: #000;
  font-size: 16px;
  font-weight: 500;
  padding-bottom: 0.2rem;
}
.box-img {
  width: 2.2rem;
  height: 2.4rem;
}
</style>
